﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DXApplicationTangche.UC.面料库存.库存记录.service;
using DXApplicationTangche.UC.项目成果管理.领料出库.service;
using DXApplicationTangche.DTO;
using mendian;
using DXApplicationTangche.UC.项目成果管理.service;
using DevExpress.XtraGrid.Demos.util;
using DXApplicationTangche.UC.项目成果管理;

namespace DXApplicationTangche.UC.工序管理.工序详情
{
    public partial class Form投料详情 : DevExpress.XtraBars.Ribbon.RibbonForm
    {
        private DTO面料库存 DTO面料库存;
        private String code;
        private String styleId;
        private DTO项目成果提交 DTO项目成果提交 = new DTO项目成果提交();
        public Form投料详情(String code)
        {
            InitializeComponent();
            this.code = code;
        }

        private void textBox扫码_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 13)
            {
                this.styleId = this.textBox扫码.Text.ToString();
                this.DTO面料库存 = 领料出库Service.get投料By扫描StyleId(this.styleId);
                if (null != this.DTO面料库存)
                {
                    show详情(DTO面料库存);
                }
            }
        }
        public void show详情(DTO面料库存 DTO面料库存)
        {
            this.textEditID.Text = DTO面料库存.id;
            this.textEdit面料号.Text = DTO面料库存.materialNo;
            this.textEdit描述名称.Text = DTO面料库存.meterialDesc;
            this.textEdit供货商.Text = DTO面料库存.vendorName;
            this.textEdit成分.Text = DTO面料库存.composition;
            this.textEdit纱织密度.Text = DTO面料库存.density;
            this.textEdit克重.Text = DTO面料库存.weight;
            this.textEdit幅宽.Text = DTO面料库存.width;
            this.textEdit厚度.Text = DTO面料库存.thick;
            this.textEdit弹力.Text = DTO面料库存.elastic;
            this.textEdit面料特性注意.Text = DTO面料库存.feature;
            this.textEdit用途.Text = DTO面料库存.uasge;
            this.textEdit延续性.Text = DTO面料库存.continuity;
            this.textEdit验料结果.Text = DTO面料库存.inspectionResults;
            this.textEdit颜色.Text = DTO面料库存.color;
            this.textEdit季节.Text = DTO面料库存.season;
            this.textEdit风格.Text = DTO面料库存.style;
            this.textEdit整理方式.Text = DTO面料库存.arrangementMethod;
            this.textEdit库存成本.Text = DTO面料库存.unitPrice.ToString();
            this.textEdit单耗.Text = DTO面料库存.fabricQuanlity.ToString();
            this.pictureBox面料图片.LoadAsync(URL.图片url + URL.面料图片路径 + RestCall.httpGetMethod(URL.接口url + "/image/getImagePath?materialCode=" + DTO面料库存.materialNo));
        }

        private void barButtonItem提交_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            this.DTO项目成果提交.code = this.code;
            this.DTO项目成果提交.batchNo = this.styleId;
            this.DTO项目成果提交.content = FunctionHelper.JsonSerialization(this.DTO面料库存);
            new Form项目成果提交(this.DTO项目成果提交).ShowDialog();
            this.textBox扫码.Focus();
        }

        private void Form投料详情_Load(object sender, EventArgs e)
        {
            this.textBox扫码.Focus();
        }
    }
}